package test;

import java.util.Random;

import movement.BasicProjectileMovement;

import jgame.JGColor;
import jgame.JGObject;

public class PaintProjectile extends AbstractProjectile {
 
	private static Random rand = new Random();
	
	// NOTE: there are both static and instance versions of all these members.
	// might not be the best way of doing things... :/ XXX
	private static final int speedFactor = 2;
	private static final int range 	= -3;
	
	private static final int baseSize = 8;
	
	private static final String name 		= "PaintProjectile";
	private static final String gfxName 	= "PaintProjectileGfx";
	
	private int frameRadius = baseSize;
	
	
	public PaintProjectile(double xPos, double yPos, double xDir, double yDir){
		// NOTE: generating random color like this might be too expensive
		super(name, null, speedFactor, speedFactor, range, xPos, yPos, 
				new JGColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)));
		
		setSpeed(speedFactor * xDir, speedFactor * yDir);
		setImage(gfxName);
		
	}
	
	public PaintProjectile(AbstractShooter gunman){
		this(gunman.x, gunman.y, gunman.getAim()[0], gunman.getAim()[1]);
	}
	
	public static void fire(AbstractShooter gunman){
		new PaintProjectile(gunman);
	}
	
	public void move(){
		//BasicProjectileMovement.getInstance().move(this);
		frameRadius = baseSize+rand.nextInt(4);
	}
	
    public void hit(JGObject obj){
        if (obj.colid == Collision.BUILDING){
            this.remove();
        }
    }

	public void paint(){
		
		
		eng.setColor(new JGColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)));
		eng.drawOval(x+frameRadius/2, y+frameRadius/2, frameRadius, frameRadius, true, true);
	}
	
}
